Misc Extension Instructions.

# MISC extension...

## Contents

- Introduction.
- Command Descriptions.
  - A=f add(B,C)
  - A=f dv(B,C)
  - A=f mul(B,C)
  - A=f sub(B,C)
  - X=fxed(Y)
  - X=fxdtoint(Y)
- Version history.
- Comming soon.
- End bit...

## Introduction.

This is a STOS extension which I have written to contain all the odds and ends which I think deserve to be in a STOS extension, but are not Falcon specific, and so do not belong in my other extension. As I am only distributing this to registered users of my Falcon extension, I guess you already know about it...

To install the extension just stick MISC.EXW into the STOS directory, and MISC.ECW into the compiler directory (if you haven't got the compiler, get it - NOW!)

At this time, the only working commands are fixed point maths routines.

## Command Descriptions

### A=f add(b,c)

This function takes two fixed point numbers (see below) and adds them together.

### A=f dv(B,C)

This function returns the fixed point value of B divided by C. (For more information about fixed numbers see below)

### A=f mul(B,C)

This function returns the fixed point value of B multiplied by C. (For more information about fixed numbers see below)

### A=f sub(B,C)

This function returns the fixed point value of C subtracted from B (ie B-C). (For more information about fixed numbers see below)

### X=fxed(Y)

When programming, it is often necessary to think about speed, as well as accuracy - Floating point maths is notorously slow without a specific piece of hardware to do it for you (an FPU). Integers are quick, but cannot represent fractions - thus, SIN and COS functions are out of the window! The solution to this problem is to use fixed point numbers - these are similar to integers, and are quick to calculate, yet can represent a limited range of fractions as well.

This extension implements some fixed point maths routines. The values are stored in normal integer variables. I have implemented a 32-bit fixed point format, with the binary point in the middle.ie

    x x x x x x x x x x x x x x x x . x x x x x x x x x x x x x x x x
     16-bit 2's complement integer              16-bit fraction

Thus, the range of the format is from -32768 to 32767, with the smallest possible fraction being 1/32768. (I think these figures are right...) Thus, it is quite possible to do calculations envolving trig. functions, or divisons in a fast way.

Accuracy is not perfect with fixed point, and it cannot handle either very large, or very small values, but is sufficiently accurate to enable fractal calculations, zooming and other mathematically based algorithms to be performed at a reasonable speed.

This function takes a value (currently, only integers are supported), and it returns the fixed point equivelent. For optimum speed, any constants should be pre-calculated, and used directly.

### X=fxedtoint(Y)

This function returns the (rounded) integer equivelent of the given fixed point number. (For more details on fixed point numbers, see above

## Version history.

I'm afraid I cannot remember exactly when I started work on this, but it must have been about June '95...

V0.1
  Implemented most fixed point routines.
  Some functions used for testing STOS Falcon Extension commands.
V0.2
  Made the compiler version and this manual.

## Comming soon.

Or, not, as the case may be... I dont often do anything to this extension, as it is not my main project, but here are some ideas that I have... If there is something particular that you would like to see here, tell me, and I'll see what I can do...

- Replacement IKBD routine - Source by Yannis - better than STOS's one!
- RGB -> HSV -> RGB conversion code.
- More fixed point maths routines.

## The End Bit...

Yes, well, not much of an extension, I know, but where else should this stuff go??? If you want to contact me, you should already have my address, but just in case you've lost it:

Home address:

Anthony Jacques
70 West Avenue
Oldfield Park
Bath, Avon
BA2 3QD

Term-time 95/96 address:

Anthony Jacques
25 Balleratt Street
Levenshulme
Manchester
M19 3DF

Email and WWW:

Email: jacquesa@cs.man.ac.uk
WWW: http://www.cs.man.ac.uk